import type { FilterItem } from '@/components/FilterBar/types'
import { getUserInfo } from '@/api/eqpt/houseManger'

import { ref } from 'vue'

export const mapOptions: FilterItem[] = [
  {
    label: '单位名称:',
    prop: 'unitName',
    type: 'input',
    span: 7,
    inputProps: {
      clearable: true,
      placeholder: '精确查询'
    }
  },
  {
    label: '培训主题:',
    prop: 'trainingTopic',
    filterable: true,
    type: 'input',
    span: 7,
    inputProps: {
      clearable: true,
      placeholder: '模糊查询'
    }
  },
  {
    label: "录入时间:",
    prop: "date",
    type: "datePicker",
    span: 7,
    defaultValue: [],
    inputProps: {
      type: "datetimerange",
      format: "YYYY-MM-DD HH:mm:ss",
      "start-placeholder": "开始时间",
      "end-placeholder": "结束时间",
      "range-separator": "至",
      "value-format": "YYYY-MM-DD HH:mm:ss",
    },
  },
  {
    label: '审核结果:',
    prop: 'isState',
    filterable: true,
    type: 'select',
    span: 7,
    defaultValue: null,
    inputProps: {
      options: [
        { label: '全部', value: null },
        { label: '未审核', value: '0' },
        { label: '审核不通过', value: '1' },
        { label: '审核通过', value: '2' }
      ]
    }
  },
  {
    label: "培训日期:",
    prop: "trainingDate",
    type: "datePicker",
    span: 7,
    inputProps: {
      clearable: true,
      placeholder: "培训日期",
      format: "YYYY-MM-DD",
      "value-format": "",
    },
  },
  {
    label: '是否有附件:',
    prop: 'isFile',
    filterable: true,
    type: 'select',
    span: 7,
    defaultValue: null,
    inputProps: {
      options: [
        { label: '全部', value: null },
        { label: '是', value: '0' },
        { label: '否', value: '1' }
      ]
    }
  },
]
export const dialogOptions = ref<Array<FilterItem>>([
  {
    label: '名称：',
    prop: 'houseName',
    type: 'input',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '类别: ',
    prop: 'houseType',
    type: 'select',
    width: "120px",
    filterable: true,
    span: 12,
    inputProps: {
      options: [{
        label: '',
        value: ''
      }]
    }
  },
  {
    label: '编号：',
    prop: 'houseCode',
    type: 'input',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '数量：',
    prop: 'num',
    type: 'inputNumber',
    width: "120px",
    span: 12,
    defaultValue: 1,
    inputProps: {
      clearable: true,
      min: 1,
      max: 1000,
      placeholder: ''
    }
  },
  {
    label: '面积：',
    prop: 'area',
    type: 'inputBtn',
    width: "120px",
    multiple: true,
    span: 12,
    inputProps: {
      clearable: true,
      unit: '㎡',
      placeholder: ''
    }
  },
  {
    label: '单价：',
    prop: 'price',
    type: 'inputBtn',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      unit: '万',
      placeholder: ''
    }
  },
  {
    label: '月租金：',
    prop: 'rent',
    type: 'inputBtn',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      min: 1,
      max: 9999999,
      unit: '元',
      placeholder: ''
    }
  },

  {
    label: '区域：',
    prop: 'region',
    type: 'select',
    width: "120px",
    span: 12,
    filterable: true,
    inputProps: {

      options: []
    }
  },
  {
    label: '地图坐标：',
    prop: 'coordinate',
    type: 'inputBtn',
    width: "120px",
    isDisabled: true,
    defaultValue: null,
    span: 12,
    icon: 'Location',
    inputProps: {
      placeholder: '请输入地图坐标',
      clearable: true
    },
    events: {
      click: () => {
      }
    }
  },
  {
    label: '使用单位：',
    prop: 'useOrgan',
    type: 'treeSelect',
    width: "120px",
    filterable: true,
    span: 12,
    inputProps: {
      'default-expand-all': true,
      data: []
    },
    events: {
      change: (value: any, evt: any) => {
        const params = ref({
          groupIds: [] as any
        })
        params.value.groupIds.length = 0
        params.value.groupIds.push(value)
        getUserInfo(params.value).then(resp => {
          const datas = ref([]) as any
          resp.data.forEach((d: any) => {
            const option = ref({
              label: d.userName,
              value: d.userId
            })
            datas.value.push(option.value)
          })
          evt.setFieldsValue({ linkUser: '' })
          evt.setOptions('linkUser', datas.value)
        })
      }
    }
  },

  {
    label: '状况：',
    prop: 'condition',
    type: 'input',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },

  {
    label: '性质：',
    prop: 'nature',
    type: 'select',
    width: "120px",
    span: 12,
    filterable: true,
    inputProps: {
      options: [{
        label: '',
        value: ''
      }]
    }
  },

  {
    label: '功能：',
    prop: 'ability',
    type: 'select',
    width: "120px",
    filterable: true,
    span: 12,
    inputProps: {
      options: []
    }
  },

  {
    label: '维保年限：',
    prop: 'maintainLimit',
    type: 'inputNumber',
    width: "120px",
    span: 12,
    filterable: true,
    inputProps: {
      clearable: true,
      min: 1,
      max: 100,
      placeholder: '请输入'
    }
  },

  {
    label: '上次维保：',
    prop: 'maintainTime',
    type: 'datePicker',
    width: "120px",
    span: 12,
    defaultValue: [],
    inputProps: {
      clearable: true,
      type: 'date'

    }
  },

  {
    label: '责任单位：',
    prop: 'dutyOrganName',
    type: 'treeSelect',
    width: "120px",
    filterable: true,
    span: 12,
    /*        isDisabled: true, */
    inputProps: {
      'default-expand-all': true,
      data: []
    }
  },

  {
    label: '联系人：',
    prop: 'linkUser',
    type: 'select',
    width: "120px",
    filterable: true,
    span: 12,
    /*        isDisabled: true, */
    inputProps: {
      options: []
    }
  },

  {
    label: '联系电话：',
    prop: 'linkPhone',
    type: 'input',
    width: "120px",
    span: 12,
    /*        isDisabled: true, */
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },

  {
    label: '楼层：',
    prop: 'floor',
    type: 'inputNumber',
    width: "120px",
    span: 12,
    inputProps: {
      clearable: true,
      min: 1,
      max: 100,
      placeholder: '请输入'

    }
  },

  {
    label: '状态：',
    prop: 'state',
    type: 'select',
    width: "120px",
    filterable: true,
    span: 12,
    /*        isDisabled: true, */
    inputProps: {
      options: [
        { label: '使用中', value: '1' },
        { label: '已废弃', value: '2' }
      ]
    }
  }

])

export const mapListFilters: FilterItem[] = [
  {
    label: '培训主题:',
    prop: 'trainingTheme',
    filterable: true,
    type: 'input',
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '单位名称:',
    prop: 'unitName',
    type: 'input',
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '单位编号:',
    prop: 'unitId',
    type: 'input',
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: "培训日期:",
    prop: "trainingDate",
    type: "datePicker",
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: "YYYY/MM/DD",
    },
  },
  {
    label: '培训场次:',
    prop: 'trainingSession',
    type: 'input',
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '参与人数:',
    prop: 'number',
    type: 'input',
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '培训人员:',
    prop: 'trainingPeople',
    type: 'input',
    span: 24,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '培训内容:',
    prop: 'trainingContent',
    type: 'input',
    span: 24,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '培训学时:',
    prop: 'trainingPeriod',
    type: 'input',
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '培训师:',
    prop: 'trainingTeacher',
    type: 'input',
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '培训时长:',
    prop: 'trainingDuration',
    type: 'input',
    span: 12,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '是否进行考核:',
    prop: 'isExamine',
    type: 'radio',
    span: 12,
    defaultValue: '',
    inputProps: {
      options: [
        { label: '是', value: '1' },
        { label: '否', value: '0' },
      ],
    },
  },
  {
    label: '培训效果评估:',
    prop: 'trainingEffect',
    type: 'input',
    span: 24,
    inputProps: {
      clearable: true,
      placeholder: ''
    }
  },
  {
    label: '有无培训台账:',
    prop: 'trainingLedger',
    type: 'select',
    span: 12,
    width: "120px",
    inputProps: {
      clearable: true,
      placeholder: "",
      options: [
        { label: "有", value: "1" },
        { label: "无", value: "2" },
      ],
    },
  },
  {
    label: '附件:',
    prop: 'annex',
    type: 'upload',
    span: 24,
    defaultValue: '',
    inputProps: {
      clearable: true,
      placeholder: '点击上传'
    }
  },
]
